<?php

/**
 * this class provides some useful functions for working with menu buttons
 * @author        simon ungerboeck <su@militaerversand.at>
 */
abstract class EasyUIMenuButton {
    private $text = null;
    private $icon = null;
    private $isPlain = null;
    private $class = null;
    private $style = null;
    private $id = null;
    private $action = null;
    private $menuId = null;
    private $disabled = null;


    /************************************************************************
     ************************** PUBLIC FUNCTIONS ****************************
     ************************************************************************/

    public function __construct($text = null) {
        if (isset($text))
            $this->text = $text;
        $this->isPlain = true;
        $this->disabled = false;
    }


    /**
     * returns the id tag for current button
     * @return         string    
     */
    public function getIdTag() {
        return (isset($this->id) ? 'id="' . $this->id . '" ' : '');
    }


    /**
     * returns the data options for current button
     * @return         string
     */
    public function getDataOptionTag() {
        $options = 'data-options="';
        $options .= (isset($this->isPlain) ? 'plain:' . (($this->isPlain) ? 'true' : 'false') . ',' : '');
        $options .= (isset($this->disabled) ? 'disabled:' . (($this->disabled) ? 'true' : 'false') . ',' : '');
        $options .= (isset($this->icon) ? 'iconCls:\'' . $this->icon . '\',' : '');
        $options .= (isset($this->menuId) ? 'menu:\'#' . $this->menuId . '\',' : '');
        $options .= '" ';
        return $options;
    }


    /**
     * returns the onclick action tag
     * @return         string
     */
    public function getActionTag() {
        return (isset($this->action) ? 'onclick="' . $this->action . '" ' : '');
    }


    /**
     * returns the style tag
     * @return     string
     */
    public function getStyleTag() {
        return (isset($this->style) ? 'style="' . $this->style . '" ' : '');
    }
    
    
    /**
     * disables the button
     */
    public function disable(){
    	$this->disabled = true;
    }


    /************************************************************************
     **************************** GETTER / SETTER ***************************
     ************************************************************************/

    public function setText($text) {
        $this->text = $text;
    }


    public function setIcon($icon) {
        $this->icon = $icon;
    }


    public function setPlain($isPlain) {
        $this->isPlain = $isPlain;
    }


    public function setStyle($style) {
        $this->style = $style;
    }


    public function setId($id) {
        $this->id = $id;
    }


    public function setAction($action) {
        $this->action = $action;
    }


    public function setMenuId($menuId) {
        $this->menuId = $menuId;
    }


    public function getText() {
        return $this->text;
    }


    public function getIcon() {
        return $this->icon;
    }


    public function isPlain() {
        return $this->isPlain;
    }


    public function getClass() {
        return $this->class;
    }


    public function getStyle() {
        return $this->style;
    }


    public function getId() {
        return $this->id;
    }


    public function getAction() {
        return $this->action;
    }


    public function getMenuId() {
        return $this->menuId;
    }

    /************************************************************************
     ************************** PRIVATE FUNCTIONS ***************************
     ************************************************************************/

}


?>